package com.example.controller;

import com.example.entity.MedicalStaff;
import com.example.service.MedicalStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/medicalStaff")
public class MedicalStaffController {

    @Autowired
    private MedicalStaffService medicalStaffService;

    // 创建工作人员信息
    @PostMapping("/add")
    public String addMedicalStaff(@RequestBody MedicalStaff staff) {
        medicalStaffService.addMedicalStaff(staff);
        return "工作人员创建成功";
    }

    // 根据ID查询工作人员
    @GetMapping("/get/{id}")
    public MedicalStaff getMedicalStaffById(@PathVariable int id) {
        return medicalStaffService.getMedicalStaffById(id);
    }

    // 查询所有工作人员
    @GetMapping("/all")
    public List<MedicalStaff> getAllMedicalStaff() {
        return medicalStaffService.getAllMedicalStaff();
    }

    // 更新工作人员信息
    @PutMapping("/update")
    public String updateMedicalStaff(@RequestBody MedicalStaff staff) {
        medicalStaffService.updateMedicalStaff(staff);
        return "工作人员信息更新成功";
    }

    // 删除工作人员
    @DeleteMapping("/delete/{id}")
    public String deleteMedicalStaff(@PathVariable int id) {
        medicalStaffService.deleteMedicalStaff(id);
        return "工作人员删除成功";
    }
}
